BUG: Deepcopy the plot saved as last_plot#1069
Merged
Merged
Conversation
plot_context stored the in-progress plot via a shallow copy, so the
object returned by last_plot() shared mutable nested state (e.g. the
theme) with the plot being built. Building mutated that shared state,
leaving last_plot() referencing a half-built plot.
As a result, code like
last_plot() + labs(subtitle="ab")
failed to left-align the title, because the title's alignment had
already been altered in the shared state during the previous build.
Use deepcopy so last_plot() is an independent, pristine snapshot.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1069 +/- ##
=======================================
Coverage 87.10% 87.10%
=======================================
Files 208 208
Lines 14321 14321
Branches 1788 1788
=======================================
Hits 12474 12474
Misses 1283 1283
Partials 564 564 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
plot_contextstored the in-progress plot via a shallow copy, so the object returned bylast_plot()shared mutable nested state (e.g. the theme) with the plot being built. Building mutated that shared state, leavinglast_plot()referencing a half-built plot.As a result, code like
failed to left-align the title, because the title's alignment had already been altered in the shared state during the previous build.
Use
deepcopysolast_plot()is an independent, pristine snapshot.